import { AfterViewInit, Component,  OnDestroy, OnInit } from '@angular/core';

@Component({
  selector: 'app-chart-load-curve',
  templateUrl: './chart-load-curve.component.html',
  styleUrls: ['./chart-load-curve.component.css']
})
export class ChartLoadCurveComponent implements OnInit {
  public chartOptions
  public data:any;
  public componentName:string="standardPowerUtilizationRate";
  public _chart: any;
  ngOnInit() {
    this.data=[
      { name: '实际负荷', data: [510, 510, 430, 430, 430, 430, 430, 430, 570, 570, 570, 590, 590, 590, 590, 470, 470, 470, 590, 590, 590, 590, 700, 700, 700]},
      { name: '计划负荷', data: [400, 400, 470, 470, 470, 470, 470, 470, 590, 590, 590, 490, 490, 490, 490, 690, 690, 690, 550, 550, 550, 550, 660, 660, 660]},
    ];
    this.fillChart(this.data);
  }
  public fillChart(data:any[]){

    let opts: any = {
      chart: {
        type: 'line',
        backgroundColor: 'transparent',
      },
      credits: {
        enabled: false
      },
      exporting: {
        enabled: false
      },
      title: {
        text: '负荷曲线',
        x: -30,
        y: 20
      },
      xAxis: {
        categories: ['0h','1h','2h','3h','4h','5h','6h','7h','8h','9h','10h','11h','12h','13h','14h','15h','16h','17h','18h','19h','20h','21h','22h','23h','24h'],
        tickInterval: 3,
      },
      yAxis: {
        title: {
          text: '负荷(MW)'
        },
        tickInterval: 200,
        // labels : {
        //   formatter : function() {   //设置纵坐标值的样式
        //     return this.value + 'MW';
        //   }
        // },
        plotLines: [{
          value: 0,
          width: 1,
          color: '#808080'
        }]
      },
      tooltip: {
        valueSuffix: 'MW'
      },
      plotOptions: {
        series: {
          marker: {
            radius: 3,
          }
        }
      },
      legend: {
        layout: 'vertical',
        align: 'top',
        x: 530,
        y: -135,
        verticalAlign: 'middle',
        borderWidth: 0
      },
      series: data
    }
    this.chartOptions = opts
  }

}
